/**
 * Copyright (c) 2010 Andrey Somov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.yaml.scalayaml.tokens

import org.yaml.scalayaml.error.Mark

object Token extends Enumeration {
    type ID = Value
    val Directive, DocumentStart, DocumentEnd, StreamStart, StreamEnd, BlockSequenceStart, BlockMappingStart,
    BlockEnd, FlowSequenceStart, FlowMappingStart, FlowSequenceEnd, FlowMappingEnd, Key, Val, BlockEntry,
    FlowEntry, Alias, Anchor, Tag, Scalar = Value
}

abstract class Token (startMark: Mark, endMark: Mark) {
    val id:Token.ID
    def is(that: Token.ID) = {
        id == that
    }
}
case class DirectiveToken[T] (name: String, value: (T, T), startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.Directive}
case class DocumentStartToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.DocumentStart}
case class DocumentEndToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.DocumentEnd}
case class StreamStartToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.StreamStart}
case class StreamEndToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.StreamEnd}
case class BlockSequenceStartToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.BlockSequenceStart}
case class BlockMappingStartToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.BlockMappingStart}
case class BlockEndToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.BlockEnd}
case class FlowSequenceStartToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.FlowSequenceStart}
case class FlowMappingStartToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.FlowMappingStart}
case class FlowSequenceEndToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.FlowSequenceEnd}
case class FlowMappingEndToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.FlowMappingEnd}
case class KeyToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.Key}
case class ValueToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.Val}
case class BlockEntryToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.BlockEntry}
case class FlowEntryToken (startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.FlowEntry}
case class AliasToken (value: String, startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.Alias}
case class AnchorToken (value: String, startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.Anchor}
case class TagToken (value: (String, String), startMark: Mark, endMark: Mark) extends Token (startMark, endMark) {val id = Token.Tag}
case class ScalarToken (value: String, plain: Boolean, startMark: Mark, endMark: Mark, style:Char = 0) extends Token (startMark, endMark) {val id = Token.Scalar}
